package HomeWork;
/*7.我们使用[0-9] [a-z][A-Z]范围内来表示字符串
示例1：
输入ppRYYGrrYBR2258
p-2
//R-2
Y-1
G-1
//r-2
//R-2
2-2
5-1
//8-1
B-1
	YrR8RrY
//Y-2
//r-2
//R-2
//8-1
输出：
Yes 8

输入:ppRYYGrrYB225
	YrR8RrY
NO*/
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class work07 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入第一个字符串:");
        String input = scanner.next();
        System.out.println("请输入第二个字符串:");
        String sequence = scanner.next();

        Map<Character, Integer> charCount = new HashMap<>();
        for (char c : input.toCharArray()) {
            charCount.put(c, charCount.getOrDefault(c, 0) + 1);
        }

        boolean flag = true;
        for (char c : sequence.toCharArray()) {
            if (charCount.containsKey(c) && charCount.get(c) > 0) {
                charCount.put(c, charCount.get(c) - 1);
            } else {
                flag = false;
                break;
            }
        }

        if (flag) {
            int remainingCount = 0;
            for (int count : charCount.values()) {
                remainingCount += count;
            }
            System.out.println("YES " + remainingCount);
        } else {
            System.out.println("NO");
        }
    }
}
